package com.study.scapp.info.qingyun.service;


import com.google.gson.Gson;
import com.study.scapp.info.common.model.Response;
import com.study.scapp.info.common.util.HttpUtil;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class QingKeYunmpl implements RobotService {

    //设置模板
    String apiTpl = "http://api.qingyunke.com/api.php?key=free&appid=0&msg=%s";
    Gson gson = new Gson();
    @Override
    public Response AI(String msg) throws UnsupportedEncodingException {

        String api = String.format(apiTpl, URLEncoder.encode(msg,"utf-8"));
        String result = HttpUtil.request(api);


        Response response = gson.fromJson(result, Response.class);
        return response;
    }
}

